package com.pt.ew.image;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

public class CharSetEncoder {

	
/**
 * Creates file with atari charset. (length 1024 bytes)
 * @param path
 * @param tileDefs
 * @throws IOException
 */
	public void writeCharset(String path, List<TileDef> tileDefs) throws IOException {
		int writedBytes = 0;
		FileOutputStream fos = new FileOutputStream(path);
		
		for (TileDef tileDef : tileDefs) {
			for (AtariCharDef charDef :tileDef.getCharDefs()) {
				byte[] bytes = charDef.getBytes();
				fos.write(bytes);
				writedBytes+=bytes.length;
			}
			
		}
		System.out.println("writed bytes =" + writedBytes);
		for (int i = writedBytes; i < 1024; i++) {
			fos.write(0); //empty byte
		}
		fos.close();
	}
}
